home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / ada / gnat-3.05- / gnat-3 / gnat-3.05-i486-linux-elf-bin / rts / 2stcmasp.adb < prev    next >
Encoding:
Text File  |  1996-06-07  |  4.4 KB  |  99 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                 GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS               --
  4. --                                                                          --
  5. --  S Y S T E M . T A S K _ C L O C K . M A C H I N E _ S P E C I F I C S   --
  6. --                                                                          --
  7. --                                  B o d y                                 --
  8. --                                                                          --
  9. --                             $Revision: 1.5 $                             --
  10. --                                                                          --
  11. --      Copyright (C) 1991,1992,1993,1994,1995 Florida State University     --
  12. --                                                                          --
  13. -- GNARL is free software; you can  redistribute it  and/or modify it under --
  14. -- terms of the  GNU General Public License as published  by the Free Soft- --
  15. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  16. -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
  17. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  18. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  19. -- for  more details.  You should have  received  a copy of the GNU General --
  20. -- Public License  distributed with GNARL; see file COPYING.  If not, write --
  21. -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
  22. -- MA 02111-1307, USA.                                                      --
  23. --                                                                          --
  24. -- As a special exception,  if other files  instantiate  generics from this --
  25. -- unit, or you link  this unit with other files  to produce an executable, --
  26. -- this  unit  does not  by itself cause  the resulting  executable  to  be --
  27. -- covered  by the  GNU  General  Public  License.  This exception does not --
  28. -- however invalidate  any other reasons why  the executable file  might be --
  29. -- covered by the  GNU Public License.                                      --
  30. --                                                                          --
  31. -- GNARL was developed by the GNARL team at Florida State University. It is --
  32. -- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
  33. -- State University (http://www.gnat.com).                                  --
  34. --                                                                          --
  35. ------------------------------------------------------------------------------
  36.  
  37. --  This package provides target machine specific Clock related definitions.
  38. --  Portability of System.Task_Clock package is accomplished separating
  39. --  this child package out. We only need to modify this package for
  40. --  different targets.
  41.  
  42. --  This version of System.Task_Clock.Machine_Specifics supports
  43. --  UNIX machines which provide microsecond timing through the
  44. --  gettimeofday() function.
  45.  
  46. --  This is a Solaris version of this package.
  47.  
  48. with Interfaces.C; use Interfaces.C;
  49.  
  50. package body System.Task_Clock.Machine_Specifics is
  51.  
  52.    -----------
  53.    -- Clock --
  54.    -----------
  55.  
  56.    type Microseconds is new long;
  57.  
  58.    Microseconds_Per_Second : Microseconds := 10#1#E6;
  59.  
  60.    subtype Fractional_Second is Microseconds range
  61.      0 .. Microseconds_Per_Second - 1;
  62.    --  This is dependent on the stdtypes.h header file.
  63.  
  64.    type time_t is new int;
  65.  
  66.    type timespec is record
  67.       tv_sec : time_t;
  68.       tv_usec : Fractional_Second;
  69.    end record;
  70.  
  71.    type timezone is record
  72.       tz_minuteswest : int;   -- of Greenwich
  73.       tz_dsttime : int;       -- type of dst correction to apply
  74.    end record;
  75.  
  76.    function gettimeofday
  77.      (tp : access timespec;
  78.       tzp : access timezone)
  79.       return int;
  80.    pragma Import (C, gettimeofday);
  81.  
  82.    function Clock return Stimespec is
  83.       Now    : aliased timespec;
  84.       Result : int;
  85.  
  86.    begin
  87.       Result := gettimeofday (Now'Access, null);
  88.       return
  89.           Stimespec_Sec_Unit * Stimespec (Now.tv_sec) +
  90.           Stimespec (Now.tv_usec) * (Stimespec_Sec_Unit /
  91.             Stimespec (Microseconds_Per_Second));
  92.    end Clock;
  93.  
  94. begin
  95.    Stimespec_Ticks := Time_Of (0, 1000000);
  96.    --  Sun os 4.1 has clock resolution of 10ms.
  97.    --  This may work for other Solaris???
  98. end System.Task_Clock.Machine_Specifics;
  99.